package org.example.yunpicturebackend.common;

import lombok.Data;
import org.example.yunpicturebackend.exception.ErrorCode;

import java.io.Serializable;

/**
 * @author Lenovo
 * 全局响应封装类
 */
@Data
public class BaseResponse<T> implements Serializable {

    //所有的接口返回给前端要返回哪些字段

    private int code;
    private T data;

    //返回是异常还是正常

    private String message;

    public BaseResponse(int code, T data, String message) {
        this.code = code;
        this.data = data;
        this.message = message;
    }
    public BaseResponse(int code, T data) {
       this(code,data,"");
    }
    public BaseResponse(ErrorCode errorCode) {
        this(errorCode.getCode(),null,errorCode.getMessage());
    }
}
